#!/usr/bin/env python

from blend import constants

class signals:
   def __init__(self,blend):
      self.blend = blend;

   def on_select_mood(self,widget,mood):
      mb = self.blend.gui.buddyWindow.moodBox;
      model = mb.get_model();
      iter = model.get_iter_first();
      while iter != None:
         if model.get_value(iter,1) == mood.int:
            mb.set_active(int(mood.id));
            break;
         iter = mb.get_model().iter_next(iter);

   def on_select_presence(self,widget,presence):
      pres = constants.C.orderedPresences.index(presence);
      self.blend.gui.buddyWindow.statusBox.set_active(pres);

   def on_show_buddy_list(self,widget):
      if not widget.get_active():
         self.blend.gui.buddyWindow.hide();
      else:
         self.blend.gui.buddyWindow.show();
         
   def on_new_im(self,widget,buddy):
      self.blend.gui.chatWindow.createNewChat(buddy,True);

   def on_click(self,widget):
      if self.blend.gui.buddyWindow.get_property('visible') == True:
         self.blend.gui.tray.displayBuddyListMenuItem.set_active(False);
      else:
         self.blend.gui.tray.displayBuddyListMenuItem.set_active(True);
      